<?php
/*
Description: This file is used to change login paassword.
*/
#########IncludeFiles####################################################################################
include_once '../inc/config.php';
include_once("../inc/bootstrape.php");
require_once _SITE_PATH_.'classes/Vendor/Vendor.php';
require_once _SITE_PATH_.'classes/Wedding/Wedding.php';
require_once _SITE_PATH_.'classes/CommonUtility/CommonUtility.php';
require_once _SITE_PATH_.'classes/Master/Master.php';

//    CHANGE PASSWORD    CODE    //           
if( $_POST['submit']=='Submit')
{    
    $parms['vendor_id'] = $_POST['vendor'];
    $parms['fixed_cost_items'] = @implode(',',$_POST['fixed_cost_items']);
    $parms['variable_cost_items'] = @implode(',',$_POST['variable_cost_items']);

    $parms['venue_id'] = $_POST['venue'];
    $parms['min_capacity'] = $_POST['min_capacity'];
    $parms['max_capacity'] = $_POST['max_capacity'];

    $parms['title'] = $_POST['title'];
    $parms['theme_id'] = $_POST['theme_id'];

    $parms['package_url'] = str_replace(' ','_',$_POST['title']);

    $parms['number_of_days'] = $_POST['number_of_days'];

    $parms['from_date'] = $_POST['from_date'];
    $parms['to_date'] = $_POST['to_date'];

    $parms['max_ceromonies'] = $_POST['max_ceromonies'];
    $parms['tags'] = $_POST['tags'];
    $parms['priority'] = $_POST['priority'];
        

    $parms['price'] = $_POST['price'];
    $parms['no_of_people'] = $_POST['no_of_people'];
    $parms['per_person_cost'] = $_POST['per_person_cost'];
    
    $parms['discount'] = $_POST['discount'];
    $parms['discount_type'] = $_POST['discount_type'];

    $parms['short_description'] = $_POST['short_description'];
    $parms['description'] = $_POST['description'];        
    $parms['booking_amount'] = $_POST['booking_amount'];

    $parms['cancellation_policy'] = $_POST['cancellation_policy'];
    $parms['tc_policy'] = $_POST['tc_policy'];

    // upload and create thumb of the image //
    if( !empty( $_FILES['package_image'] ) ){
        $filename  = 'package_image';     //  this is name of the control you are using in html form         
        $module='wedpkg';
        $uploadedfile = CommonUtility::uploadNcreateThumb($filename, $module, true, 100, true);
        if( $uploadedfile!= -1 )    {
            $parms['package_image'] = $uploadedfile;//$_POST['package_image'];
        }        
    }
    
    $wedding_id = CommonUtility::insertData($parms, 'wedding_package','id');

    if(is_int($wedding_id)){        

        // upload and create thumb of the image //
        if( !empty($_FILES['wedding_images'] ) ){
            $parms_wedding_images = array();
            $filename  = 'wedding_images';     //  this is name of the control you are using in html form    
            $uploadedfile = CommonUtility::uploadNcreateThumb($filename, $module='wedpkg', true, 100, true);
        
            if( $uploadedfile != -1 )    {
                $parms_wedding_images['entity_type'] = '3';
                $parms_wedding_images['entity_id'] = $wedding_id;

                $i = 0;
                foreach($uploadedfile as $key => $val){
                    $parms_wedding_images['image'] = $val;
                    $parms_wedding_images['image_title'] = $_POST['image_title'][$i];
                    $parms_wedding_images['image_tooltip'] = $_POST['image_tooltip'][$i];
                    $parms_wedding_images['image_description'] = $_POST['image_description'][$i];
                    $parms_wedding_images['added'] = date("Y-m-d");
                    CommonUtility::insertData($parms_wedding_images,'site_galleries');
                    $i++;
                }
                
            }
        }

        if(!empty($_POST['wedding_specification'])){
            $i = 0;
            $filename = 'wedpg_days_image';
            $params_wedding_specification = array();
            $params_wedding_specification['wedding_id'] = $wedding_id;

            // upload and create thumb of the image //
            if( !empty($_FILES['wedpg_days_image'] ) ){
                $wedpg_days_image = CommonUtility::uploadNcreateThumb($filename, $module='wedpkg_days_specification', true, 100);
            }

            foreach($_POST['wedding_specification'] as $key => $val){
                $params_wedding_specification['wedding_specification'] = $val;
                $params_wedding_specification['venue_id'] = $_POST['cbo_venues'][$i];
                $params_wedding_specification['image'] = isset($wedpg_days_image[$i])?$wedpg_days_image[$i]:'';
                CommonUtility::insertData($params_wedding_specification, 'wedding_schedule_specification');
                $i++;
            } 
        }
        
        header("Location: wedding_mng.php?msg=1034");            
        exit;
    }
    $err = 1035;    
}

//$wedding_inclusion = Master::getInclusion($_POST['inclusion']);
//$wedding_exclusion = Master::getInclusion($_POST['exclusion']);
$editor = CommonUtility::includeEditor();

$errMsg = $err;
$_tplName = 'wedding/wedding_add.tpl';
$_title = 'Add Wedding Package';

//  calender js include
$_extraJS[] = _SITE_URL_ . 'lib/calender/js/cal.js';
require_once _ADMIN_TPL_MAIN_;
?>